﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Documents;

namespace Zero.UControl.Demo.Views.UAdorner.Component
{
    public abstract class ElementDecoratorBase : Adorner, IElementDecorator
    {
        protected UIElement _element;
        protected Canvas _canvas;

        protected ElementDecoratorBase(UIElement adornedElement) : base(adornedElement)
        {
        }

        public virtual void Attach(UIElement element, Canvas canvas)
        {
            _element = element;
            _canvas = canvas;

            var adornerLayer = AdornerLayer.GetAdornerLayer(element);
            if (adornerLayer != null)
            {
                adornerLayer.Add(this);
            }
        }
        public virtual void Dettach(UIElement element) { }
    }

}
